package com.lagou.homework4;

public class TicketerBunker {
    int tickets = 0;
    int totalnum = 0;
    public void setTickets(int tickets) {
        this.tickets = tickets;
        this.totalnum = tickets;
    }

    public synchronized int  getTickets(String name) {
        if (this.tickets <= 0){
            System.out.println("票不够了");
            return 0;
        }
        this.tickets--;
        System.out.println(name + "取走了第" + (this.totalnum - this.tickets)+"张票");
        return tickets;
    }
}
